<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="cliente" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{clienteHome.managed ? 'Edit' : 'Add'} Cliente</f:facet>



            <s:decorate id="apellidoField" template="layout/edit.xhtml">
                <ui:define name="label">Apellido</ui:define>
                <h:inputText id="apellido"
                       required="true"
                           size="50"
                      maxlength="50"
                          value="#{clienteHome.instance.apellido}">
                    <a:support event="onblur" reRender="apellidoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="celularField" template="layout/edit.xhtml">
                <ui:define name="label">Celular</ui:define>
                <h:inputText id="celular"
                           size="12"
                      maxlength="12"
                          value="#{clienteHome.instance.celular}">
                    <a:support event="onblur" reRender="celularField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="direccionField" template="layout/edit.xhtml">
                <ui:define name="label">Direccion</ui:define>
                <h:inputText id="direccion"
                           size="12"
                      maxlength="12"
                          value="#{clienteHome.instance.direccion}">
                    <a:support event="onblur" reRender="direccionField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="emailField" template="layout/edit.xhtml">
                <ui:define name="label">Email</ui:define>
                <h:inputText id="email"
                           size="50"
                      maxlength="50"
                          value="#{clienteHome.instance.email}">
                    <a:support event="onblur" reRender="emailField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>



            <s:decorate id="nombreField" template="layout/edit.xhtml">
                <ui:define name="label">Nombre</ui:define>
                <h:inputText id="nombre"
                       required="true"
                           size="50"
                      maxlength="50"
                          value="#{clienteHome.instance.nombre}">
                    <a:support event="onblur" reRender="nombreField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="numeroDocumentoField" template="layout/edit.xhtml">
                <ui:define name="label">Numero documento</ui:define>
                <h:inputText id="numeroDocumento"
                           size="12"
                      maxlength="12"
                          value="#{clienteHome.instance.numeroDocumento}">
                    <a:support event="onblur" reRender="numeroDocumentoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="telefonoFijoField" template="layout/edit.xhtml">
                <ui:define name="label">Telefono fijo</ui:define>
                <h:inputText id="telefonoFijo"
                           size="12"
                      maxlength="12"
                          value="#{clienteHome.instance.telefonoFijo}">
                    <a:support event="onblur" reRender="telefonoFijoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{clienteHome.persist}"
                       disabled="#{!clienteHome.wired}"
                       rendered="#{!clienteHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{clienteHome.update}"
                       rendered="#{clienteHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{clienteHome.remove}"
                      immediate="true"
                       rendered="#{clienteHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Cliente.xhtml"
                rendered="#{clienteHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty clienteFrom ? 'ClienteList' : clienteFrom}.xhtml"
                rendered="#{!clienteHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Tipo documento">
    <div class="association" id="tipoDocumentoParent">

        <h:outputText value="There is no tipoDocumento associated with this cliente."
                   rendered="#{clienteHome.instance.tipoDocumento == null}"/>

        <rich:dataTable var="_tipoDocumento"
                   value="#{clienteHome.instance.tipoDocumento}"
                rendered="#{clienteHome.instance.tipoDocumento != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="tipoDocumentoTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_tipoDocumento.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Descripcion</f:facet>
                <h:outputText value="#{_tipoDocumento.descripcion}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{clienteHome.instance.tipoDocumento != null ? 'changeParenttipoDocumento' : 'selectParenttipoDocumento'}" value="#{clienteHome.instance.tipoDocumento != null ? 'Change' : 'Select'} tipoDocumento"
                       view="/TipoDocumentoList.xhtml">
                <f:param name="from" value="ClienteEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
